# python 验证用户名密码是否规范
# https://www.bilibili.com/video/BV1P14y1L7kP/?spm_id_from=333.999.0.0&vd_source=ffde1e6c5946d5428a8146c8880b2bc9

import re


def check_password(password):
    if not 6 <= len(password) <= 20:
        return False, "Password must be between 6 and 20 characters"
    if not re.search(r"[A-Z]", password):
        return False, "必须包含至少1个大写字母"
    if not re.search(r"[a-z]", password):
        return False, "必须包含至少1个小写字母"
    if not re.search(r"[0-9]", password):
        return False, "必须包含至少1个数字"
    if not re.search(r"[^0-9a-zA-z]", password):
        return False, "必须包含至少1个特殊字符"


print(check_password("111"))
print(check_password("aaa111"))
